﻿// Original author contact info: Owen Emlen (owene_1998@yahoo.com)
// Note: other individuals may also have contributed to this code
// Project hosted on CodePlex.com as of 1/10/2009 at http://www.codeplex.com/EmlenMud
using System;
using BrainTechLLC.ThreadSafeObjects;

namespace BrainTechLLC
{
    /// <summary>
    /// Logs messages (using an implementation of ILogger)
    /// Provides global access to / sets the implementation of the logger 
    /// </summary>
    public static class GlobalLogger
    {
        private static ILogger _logger;

        public static ILogger Logger
        {
            get { return _logger; }
        }

        public static void Log(string messageType, string message, LogSeverity severity)
        {
            if (_logger != null)
            {
                _logger.Log(messageType, message, severity);
            }
        }

        public static void Log(this Exception ex, LogSeverity severity, bool verbose)
        {
            if (_logger != null)
            {
                _logger.Log(ex, severity, verbose);
            }
        }

        public static void Log(this Exception ex, string message, LogSeverity severity, bool verbose)
        {
            if (_logger != null)
            {
                _logger.Log(ex, message, severity, verbose);
            }
        }

        public static void RegisterLogger(ILogger logger)
        {
            _logger = logger;
        }
    }
}